var manufacturerData = [];

$(document).ready(function() {
	showLoading();
	$('title', parent.document).html($('title').text());
	setBaseUrl();
	addTitle("manufacturerUpdate");
	search();
})

function search(){
	$('#ManufacturerName').val($("#detailID", parent.document).val());
	$ajax('searchManufacturerInfo', 'searchManufacturerInfoUpdate', searchManufacturer);
	$("#detailID", parent.document).val("");
	setTimeout(hideLoading, 500);
}
function searchManufacturer(data){
	manufacturerData = data && data.manufacturerList || [];
	createComBody("detailOneBody", manufacturerTable, manufacturerData[0], 1);
	$("#manufacturerID").attr("readonly", true);
	if(manufacturerData[0].enabled == true){
		$("#enabled").val(1);
	}else{
		$("#enabled").val(0);
	}
}
function updateManufacturerInfo(data){
     var result = data && data.result;
     if (result == "Success"){
    	 showMessge(messageContent["Update.Success"], undefined, goback);
     } else if (result == "NotFound"){
    	 showMessge(messageContent["Update.Failed"]);
     } else if (result == "UserIDNoNull"){
         showMessge(messageContent["UserIDNoNull"]);
     } else{
    	 showMessge(messageContent["Update.Error"]);
     }
}
function confirm(){
	return checkForm("saveForm", manufacturerTable);
}
function goback() {
	window.parent.skipMenu('vehicle/manufacturer', 'drownDown3', '', 'carPage', 'manufacturer');
}